package cn.lystudio.rohmtimeopwide_background_v11.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ConcurrentHashSet;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.lystudio.rohmtimeopwide_background_v11.entity.dto.MachineDTO;
import cn.lystudio.rohmtimeopwide_background_v11.entity.dto.ShiftCapacityRecordDTO;
import cn.lystudio.rohmtimeopwide_background_v11.entity.po.MachinePO;
import cn.lystudio.rohmtimeopwide_background_v11.entity.po.PlanOutputPO;
import cn.lystudio.rohmtimeopwide_background_v11.entity.po.ShiftCapacityRecordPO;
import cn.lystudio.rohmtimeopwide_background_v11.entity.po.UsersPO;
import cn.lystudio.rohmtimeopwide_background_v11.entity.vo.Capa4ExcelVO;
import cn.lystudio.rohmtimeopwide_background_v11.entity.vo.ConsoleCapaChartVO;
import cn.lystudio.rohmtimeopwide_background_v11.entity.vo.ShiftCapacityRecordVO;
import cn.lystudio.rohmtimeopwide_background_v11.exceptions.JsonException;
import cn.lystudio.rohmtimeopwide_background_v11.mapper.ShiftCapacityRecordMapper;
import cn.lystudio.rohmtimeopwide_background_v11.mapper.UsersPOMapper;
import cn.lystudio.rohmtimeopwide_background_v11.service.MachineService;
import cn.lystudio.rohmtimeopwide_background_v11.service.PlanOutputService;
import cn.lystudio.rohmtimeopwide_background_v11.service.ShiftCapacityRecordService;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.function.Function;

@Slf4j
@Service
@DS("master")

public class ShiftCapacityRecordServiceImpl implements ShiftCapacityRecordService {
    @Resource
    private ShiftCapacityRecordMapper shiftCapacityRecordMapper;
    @Resource
    private UsersPOMapper usersPOMapper;
    private MachineService machineService;
    private PlanOutputService planOutputService;
    @Lazy
    @Autowired
    public void setPlanOutputService(PlanOutputService planOutputService) {
        this.planOutputService = planOutputService;
    }
    @Autowired
    @Lazy
    public void setMachineService(MachineService machineService) {
        this.machineService = machineService;
    }

    @Override
    public List<ShiftCapacityRecordDTO> getAll(String machineNo,
                                               String searchStartTime,
                                               String searchEndTime,
                                               String otherKeywords) {
        // 1. 获取所有设备
        List<MachineDTO> machineDTOList = machineService.getAll(null);
        // 1.1 组装machineNoList
        Set<String> machineNoList = new ConcurrentHashSet<>();
        CollUtil.forEach(machineDTOList.iterator(), (machineDTO, index) -> {
            machineNoList.add(machineDTO.getMachine().getMachineNo());
        });
        // 2.获取所有记录
        LambdaQueryWrapper<ShiftCapacityRecordPO> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(ShiftCapacityRecordPO::getMachineNo, machineNoList)
                .like(StrUtil.isNotEmpty(machineNo), ShiftCapacityRecordPO::getMachineNo, machineNo)
                .and(StrUtil.isNotEmpty(searchStartTime) && StrUtil.isNotEmpty(searchEndTime), i -> {
                    i.between(ShiftCapacityRecordPO::getRecordTimeDT, searchStartTime, searchEndTime);
                })
                .and(StrUtil.isNotEmpty(otherKeywords), i -> {
                    i.like(ShiftCapacityRecordPO::getRecordRemark, otherKeywords)
                            .or()
                            .like(ShiftCapacityRecordPO::getUserCode, otherKeywords);
                })
                .orderByDesc(ShiftCapacityRecordPO::getRecordTimeDT);
        List<ShiftCapacityRecordPO> shiftCapacityRecordPOList = shiftCapacityRecordMapper.selectList(wrapper);
        if (CollUtil.isEmpty(shiftCapacityRecordPOList)) return null;
        // 3.获取所有人员信息
        List<UsersPO> usersPOList = usersPOMapper.selectList(null);
        // 4.组装view层数据
        List<ShiftCapacityRecordDTO> shiftCapacityRecordDTOList = CollUtil.list(false);
        CollUtil.forEach(shiftCapacityRecordPOList.iterator(), (shiftCapacityRecordPO, index) -> {
            ShiftCapacityRecordDTO shiftCapacityRecordDTO = new ShiftCapacityRecordDTO();
            shiftCapacityRecordDTO.setShiftCapacityRecord(shiftCapacityRecordPO);
            if (StrUtil.isNotEmpty(shiftCapacityRecordPO.getMachineNo())) {
                shiftCapacityRecordDTO.setMachine(
                        CollUtil.findOne(machineDTOList, machineDTO -> machineDTO.getMachine().getMachineNo().equals(shiftCapacityRecordPO.getMachineNo()))
                );
            }
            if (StrUtil.isNotEmpty(shiftCapacityRecordPO.getUserCode())) {
                shiftCapacityRecordDTO.setUser(
                        CollUtil.findOne(usersPOList, usersPO -> usersPO.getUserCode().equals(shiftCapacityRecordPO.getUserCode()))
                );
            }
            shiftCapacityRecordDTOList.add(shiftCapacityRecordDTO);
        });
        // 5.过滤数据
        CollUtil.removeNull(shiftCapacityRecordDTOList);
        return shiftCapacityRecordDTOList;
    }

    @Override
    public int delShiftCapacityRecord(Integer shiftCapaRecordID) {
        return shiftCapacityRecordMapper.deleteById(shiftCapaRecordID);
    }

    @Override
    public int uptShiftCapacityRecord(ShiftCapacityRecordPO shiftCapacityRecordPO) {
        return shiftCapacityRecordMapper.updateById(shiftCapacityRecordPO);
    }

    /**
     * 给首页产量数据的表格组织数据
     */
    @Override
    public List<ShiftCapacityRecordDTO> getDailyData(String machineNo, String dailyStart, String dailyEnd) {
        LambdaQueryWrapper<ShiftCapacityRecordPO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ShiftCapacityRecordPO::getMachineNo, machineNo)
                //.between(ShiftCapacityRecordPO::getRecordTimeDT, dailyStart, dailyEnd);
                .gt(ShiftCapacityRecordPO::getRecordTimeDT,dailyStart)
                .le(ShiftCapacityRecordPO::getRecordTimeDT,dailyEnd);
        List<ShiftCapacityRecordPO> dailyDataList = shiftCapacityRecordMapper.selectList(wrapper);
        if(CollUtil.isEmpty(dailyDataList)) return null;
        // 组装数据
        List<ShiftCapacityRecordDTO> resDailyDataList = CollUtil.list(false);
        CollUtil.forEach(dailyDataList.iterator(), (dailyData, index) -> {
            ShiftCapacityRecordDTO shiftCapacityRecordDTO = new ShiftCapacityRecordDTO();
            shiftCapacityRecordDTO.setShiftCapacityRecord(dailyData);
            shiftCapacityRecordDTO.setUser(
                    usersPOMapper.selectOne(new LambdaQueryWrapper<UsersPO>().eq(UsersPO::getUserCode, dailyData.getUserCode()).last("LIMIT 1"))
            );
            resDailyDataList.add(shiftCapacityRecordDTO);
        });
        // 过滤数据
        CollUtil.filter(resDailyDataList, shiftCapacityRecordDTO -> {
            int tmpHour= DateUtil.hour(DateUtil.date(shiftCapacityRecordDTO.getShiftCapacityRecord().getRecordTimeDT()),true);
            if(tmpHour==7 || tmpHour==19) return true;
            return false;
        });
        return resDailyDataList;
    }

    /**
     * 给数据图准备数据
     */
    @Override
    public List<ShiftCapacityRecordDTO> getDailyData4Dashboard(String machineNo, String dailyStart, String dailyEnd) {
        List<ShiftCapacityRecordDTO> dailyDataList= CollUtil.list(false);
        ShiftCapacityRecordDTO capacityRecordDTO1 = new ShiftCapacityRecordDTO();
        ShiftCapacityRecordDTO capacityRecordDTO2 = new ShiftCapacityRecordDTO();
        /*
        capacityRecord1.setRecordTimeDT(DateUtil.parse(DateUtil.format(DateUtil.parse(dailyStart),"yyyy-MM-dd")+ " 07:00:00"));
        capacityRecordDTO1.setShiftCapacityRecord(capacityRecord1);
        dailyDataList.add(capacityRecordDTO1);

        capacityRecord2.setRecordTimeDT(DateUtil.parse(DateUtil.format(DateUtil.parse(dailyStart),"yyyy-MM-dd")+ " 19:00:00"));

        if(DateUtil.hour(DateUtil.date(),true)<=8 || DateUtil.hour(DateUtil.date(),true)>=20 ){
            capacityRecordDTO2.setShiftCapacityRecord(capacityRecord2);
            dailyDataList.add(capacityRecordDTO2);
        }

         */
        // 2.1 获取1值最近的产量
        LambdaQueryWrapper<ShiftCapacityRecordPO> wrapper1 = new LambdaQueryWrapper<>();
        wrapper1.eq(ShiftCapacityRecordPO::getMachineNo,machineNo)
                .gt(ShiftCapacityRecordPO::getRecordTimeDT,DateUtil.format(DateUtil.parse(dailyStart, "yyyy-MM-dd"), "yyyy-MM-dd") + " 07:00:00")
                .le(ShiftCapacityRecordPO::getRecordTimeDT,DateUtil.format(DateUtil.parse(dailyStart, "yyyy-MM-dd"), "yyyy-MM-dd") + " 19:00:00")
                .orderByDesc(ShiftCapacityRecordPO::getRecordTimeDT)
                .last("LIMIT 1");
        ShiftCapacityRecordPO capacityRecord1 = shiftCapacityRecordMapper.selectOne(wrapper1);
        if(ObjectUtil.isEmpty(capacityRecord1)) {
            capacityRecord1=new ShiftCapacityRecordPO();
            capacityRecord1.setRecordTimeDT(DateUtil.parse(DateUtil.format(DateUtil.parse(dailyStart),"yyyy-MM-dd")+ " 07:00:00"));
        }

        capacityRecordDTO1.setShiftCapacityRecord(capacityRecord1);
        dailyDataList.add(capacityRecordDTO1);

        //2.2 获取2值数据

        LambdaQueryWrapper<ShiftCapacityRecordPO> wrapper2 = new LambdaQueryWrapper<>();
        wrapper2.eq(ShiftCapacityRecordPO::getMachineNo,machineNo)
                .gt(ShiftCapacityRecordPO::getRecordTimeDT,DateUtil.format(DateUtil.parse(dailyStart, "yyyy-MM-dd"), "yyyy-MM-dd") + " 19:00:00")
                .le(ShiftCapacityRecordPO::getRecordTimeDT,DateUtil.format(DateUtil.parse(dailyEnd, "yyyy-MM-dd"), "yyyy-MM-dd") + " 07:00:00")
                .orderByDesc(ShiftCapacityRecordPO::getRecordTimeDT)
                .last("LIMIT 1");
        ShiftCapacityRecordPO capacityRecord2 = shiftCapacityRecordMapper.selectOne(wrapper2);

        if(ObjectUtil.isEmpty(capacityRecord2) )  {
            capacityRecord2=new ShiftCapacityRecordPO();
            capacityRecord2.setRecordTimeDT(DateUtil.parse(DateUtil.format(DateUtil.parse(dailyStart),"yyyy-MM-dd")+ " 19:00:00"));
        };

        capacityRecordDTO2.setShiftCapacityRecord(capacityRecord2);
        dailyDataList.add(capacityRecordDTO2);

        //4.组装最后数据
        CollUtil.forEach(dailyDataList.iterator(),(shiftCapacityRecordDTO,index)->{
            if(ObjectUtil.isNotEmpty(shiftCapacityRecordDTO)){
                if(StrUtil.isNotEmpty(shiftCapacityRecordDTO.getShiftCapacityRecord().getUserCode())){
                    shiftCapacityRecordDTO.setUser(usersPOMapper.selectOne(new LambdaQueryWrapper<UsersPO>().eq(UsersPO::getUserCode,shiftCapacityRecordDTO.getShiftCapacityRecord().getUserCode())));

                }
            }

        });
        return dailyDataList;
    }

    /**
     * 给首页产量图组织数据
     */
    @Override
    public ConsoleCapaChartVO getDailyData4Chart(String machineNo, String dailyStart, String dailyEnd) {
      return null;
			/*
			LambdaQueryWrapper<ShiftCapacityRecordPO> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ShiftCapacityRecordPO::getMachineNo, machineNo)
                //.between(ShiftCapacityRecordPO::getRecordTimeDT, dailyStart, dailyEnd);
                .gt(ShiftCapacityRecordPO::getRecordTimeDT,dailyStart)
                .le(ShiftCapacityRecordPO::getRecordTimeDT,dailyEnd)
                .orderByDesc(ShiftCapacityRecordPO::getRecordTimeDT);
        List<ShiftCapacityRecordPO> capaList = shiftCapacityRecordMapper.selectList(wrapper);
        ConsoleCapaChartVO consoleCapaChartVO=new ConsoleCapaChartVO();
        List<Integer> tmpActualList = new ArrayList<>();
        List<Integer> tmpPlanList = new ArrayList<>();
        //填充0
        for(int i=0;i<13;i++){
            tmpActualList.add(0);
            tmpPlanList.add(0);
        }
        consoleCapaChartVO.setActualOutputList(tmpActualList);
        consoleCapaChartVO.setPlanOutputList(tmpPlanList);
        // 获取设置计划值
        int planOutput1 =0 ;
        PlanOutputPO planOutputPO1 = planOutputService.getPlanOutput(machineNo, 1);
        if (ObjectUtil.isNotEmpty(planOutputPO1)) planOutput1=planOutputPO1.getPlanOutput();

        for(int i=1;i<7;i++){
            if(i==6){
                tmpPlanList.set(i,planOutput1);
                continue;
            }
            tmpPlanList.set(i,(planOutput1*(i*2)/12));
        }
        int planOutput2 =0 ;
        PlanOutputPO planOutputPO2 = planOutputService.getPlanOutput(machineNo, 2);
        if(ObjectUtil.isNotEmpty(planOutputPO2)) planOutput2=planOutputPO2.getPlanOutput();
        for(int i=1;i<7;i++){
            if(i==6){
                tmpPlanList.set(i+6,planOutput2);
                continue;
            }
            tmpPlanList.set(i+6,(planOutput2-planOutput1)*(i*2)/12+planOutput1);
        }
        // 计算实际值
        CollUtil.forEach(capaList.iterator(), (shiftCapacityRecordPO, index) -> {
            Date recordTimeDT = shiftCapacityRecordPO.getRecordTimeDT();
            int hour = DateUtil.hour(recordTimeDT, true);
            switch (hour){
                case 9:
                    tmpActualList.set(1,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(1,shiftCapacityRecordPO.getPlanOutput());
                    break;
                case 11:
                    tmpActualList.set(2,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(2,shiftCapacityRecordPO.getPlanOutput());
                    break;
                case 13:
                    tmpActualList.set(3,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(3,shiftCapacityRecordPO.getPlanOutput());
                    break;
                case 15:
                    tmpActualList.set(4,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(4,shiftCapacityRecordPO.getPlanOutput());
                    break;
                case 17:
                    tmpActualList.set(5,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(5,shiftCapacityRecordPO.getPlanOutput());
                    break;
                case 19:
                    tmpActualList.set(6,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(6,shiftCapacityRecordPO.getPlanOutput());
                    break;
                case 21:
                    tmpActualList.set(7,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(7,shiftCapacityRecordPO.getPlanOutput());
                    break;
                case 23:
                    tmpActualList.set(8,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(8,shiftCapacityRecordPO.getPlanOutput());
                    break;
                case 1:
                    tmpActualList.set(9,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(9,shiftCapacityRecordPO.getPlanOutput());
                    break;
                case 3:
                    tmpActualList.set(10,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(10,shiftCapacityRecordPO.getPlanOutput());
                    break;
                case 5:
                    tmpActualList.set(11,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(11,shiftCapacityRecordPO.getPlanOutput());
                    break;
                case 7:
                    if(DateUtil.format(recordTimeDT,"yyyy-MM-dd").equals(DateUtil.format(DateUtil.parse(dailyStart),"yyyy-MM-dd"))){
                        break;
                    }
                    tmpActualList.set(12,shiftCapacityRecordPO.getActualOutput());
                    tmpPlanList.set(12,shiftCapacityRecordPO.getPlanOutput());
                    break;
                default:
                    break;
            }
        });
        consoleCapaChartVO.setMachineNo(machineNo);
        return consoleCapaChartVO;
        */

    }

    /**
     * APP入力产量时,显示一下已经入力的产量
     */
    @Override
    public List<ShiftCapacityRecordVO> getShiftCapaRecordTimeLine(String machineNo, String beginDate, String endDate) {
        return shiftCapacityRecordMapper.getShiftCapaRecordTimeLine(machineNo,beginDate,endDate);
    }

    /**
     * APP入力产量
     */
    @Override
    public int addShiftCapacityRecord(ShiftCapacityRecordPO shiftCapacityRecordPO) {
        return shiftCapacityRecordMapper.insert(shiftCapacityRecordPO);
    }

    @Override
    public ShiftCapacityRecordPO getShiftCapacityRecordByID(int shiftCapaRecordID) {
        return shiftCapacityRecordMapper.selectById(shiftCapaRecordID);
    }

    @Override
    public Capa4ExcelVO getCapa4Excel(String selectedMachineNo, String selectedDate) {
        LambdaQueryWrapper<ShiftCapacityRecordPO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ShiftCapacityRecordPO::getMachineNo,selectedMachineNo)
            .like(ShiftCapacityRecordPO::getRecordTimeDT,selectedDate);
        List<ShiftCapacityRecordPO> shiftCapacityRecordPOS = shiftCapacityRecordMapper.selectList(queryWrapper);
        if(shiftCapacityRecordPOS.size()>2) throw new JsonException(500,"产量数据异常");
        if(shiftCapacityRecordPOS.size()<1) return null;
        // 组装数据
        Capa4ExcelVO capa4ExcelVO = new Capa4ExcelVO();
        CollUtil.forEach(shiftCapacityRecordPOS.iterator(),(shiftCapacityRecordPO, i) -> {
           if( StrUtil.equals(DateUtil.format(shiftCapacityRecordPO.getRecordTimeDT(),"HH"),"08") ) {
               capa4ExcelVO.setDayPlanOutput(shiftCapacityRecordPO.getPlanOutput());
               capa4ExcelVO.setDayActualCommonOutput(shiftCapacityRecordPO.getActualCommonOutput());
               capa4ExcelVO.setDayActualHROutput(shiftCapacityRecordPO.getActualHROutput());
               capa4ExcelVO.setDayBj2Output(shiftCapacityRecordPO.getBj2Output());
               capa4ExcelVO.setDayDsOutput(shiftCapacityRecordPO.getDsOutput());
               capa4ExcelVO.setDayDefectOutput(shiftCapacityRecordPO.getDefect());
           } else if( StrUtil.equals(DateUtil.format(shiftCapacityRecordPO.getRecordTimeDT(),"HH"),"20") ) {
               capa4ExcelVO.setNightPlanOutput(shiftCapacityRecordPO.getPlanOutput());
               capa4ExcelVO.setNightActualCommonOutput(shiftCapacityRecordPO.getActualCommonOutput());
               capa4ExcelVO.setNightActualHROutput(shiftCapacityRecordPO.getActualHROutput());
               capa4ExcelVO.setNightBj2Output(shiftCapacityRecordPO.getBj2Output());
               capa4ExcelVO.setNightDsOutput(shiftCapacityRecordPO.getDsOutput());
               capa4ExcelVO.setNightDefectOutput(shiftCapacityRecordPO.getDefect());
           } else {
               throw new JsonException(500,"数据异常");
           }
        });
        if(ObjectUtil.isEmpty(shiftCapacityRecordPOS)) throw new JsonException(500,"数据异常");
        // 计算合计数
        capa4ExcelVO.setSumHROutput(NumberUtil.add(capa4ExcelVO.getDayActualHROutput(),capa4ExcelVO.getNightActualHROutput()));
        capa4ExcelVO.setSumCommonOutput(NumberUtil.add(capa4ExcelVO.getDayActualCommonOutput(),capa4ExcelVO.getNightActualCommonOutput()));
        capa4ExcelVO.setSumBj2Output(NumberUtil.add(capa4ExcelVO.getDayBj2Output(),capa4ExcelVO.getNightBj2Output()));
        capa4ExcelVO.setSumDsOutput(NumberUtil.add(capa4ExcelVO.getDayDsOutput(),capa4ExcelVO.getNightDsOutput()));
        capa4ExcelVO.setSumDefectOutput(NumberUtil.add(capa4ExcelVO.getDayDefectOutput(),capa4ExcelVO.getNightDefectOutput()));
        capa4ExcelVO.setSumPlanOutput(NumberUtil.add(capa4ExcelVO.getDayPlanOutput(),capa4ExcelVO.getNightPlanOutput()));
        capa4ExcelVO.setDaySum(NumberUtil.add(StrUtil.toStringOrNull(capa4ExcelVO.getDayActualCommonOutput()) ,
                                                StrUtil.toStringOrNull(capa4ExcelVO.getDayActualHROutput()),
                                                StrUtil.toStringOrNull(capa4ExcelVO.getDayBj2Output()),
                                                StrUtil.toStringOrNull(capa4ExcelVO.getDayDsOutput())
                                            ).doubleValue());
        capa4ExcelVO.setNightSum(NumberUtil.add(StrUtil.toStringOrNull(capa4ExcelVO.getNightActualCommonOutput()),
                                                StrUtil.toStringOrNull(capa4ExcelVO.getNightActualHROutput()),
                                                StrUtil.toStringOrNull(capa4ExcelVO.getNightBj2Output()),
                                                StrUtil.toStringOrNull(capa4ExcelVO.getNightDsOutput())
                                            ).doubleValue());
        capa4ExcelVO.setAllSum(NumberUtil.add(StrUtil.toStringOrNull(capa4ExcelVO.getDaySum()),StrUtil.toStringOrNull(capa4ExcelVO.getNightSum())).doubleValue());

        return capa4ExcelVO;
    }

    @Override
    public List<ShiftCapacityRecordPO> getCapa4Home(Integer secDeptID,Integer machineType, String selectDate) {
        //1.查询secDeptID下所有机台
        List<MachinePO> machineListBySecDeptID = machineService.getMachineListBySecDeptID_machineTYpe(secDeptID,machineType);
        //1.1 组织数据, 获取机台List
        List<String> machineNoList = CollUtil.newArrayList();
        CollUtil.forEach(machineListBySecDeptID, (machinePO, i) -> {
            machineNoList.add(machinePO.getMachineNo());
        });
        if(CollUtil.isEmpty(machineNoList)) return null;

        //2.查询产量数据
        //LambdaQueryWrapper<ShiftCapacityRecordPO> wrapper=new LambdaQueryWrapper<>();
        //wrapper.like(ShiftCapacityRecordPO::getRecordTimeDT,selectDate)
        //    .in(ShiftCapacityRecordPO::getMachineNo,machineNoList);
        //List<ShiftCapacityRecordPO> tmpList = shiftCapacityRecordMapper.selectList(wrapper);

        List<ShiftCapacityRecordPO> capa4Home = shiftCapacityRecordMapper.getCapa4Home(machineNoList, selectDate);
        return capa4Home;
    }


}
